const login = require('../service/login')

const getPhoneCode = async (ctx) =>{
    let res = await login.getRanderCode(ctx.request.body)
    if(res.length > 0){
        return ctx.body = {
            code:20000,
            data:res,
            msg:'验证码发送成功'
        }
    }
}

// 判断输入的验证码是否正确
const checkPhoneCode = async (ctx) =>{
    let res = await login.checkCode(ctx.query)
    if(res.length > 0){
        return ctx.body = {
            code:20000,
            msg:'验证码正确'
        }
    }else{
         return ctx.body = {
            code:40001,
            msg:'手机号或验证码有误'
        }
    }
}

module.exports ={
    getPhoneCode,
    checkPhoneCode
}